package com.bw.user.controller;


import cn.hutool.core.util.ObjectUtil;
import com.bw.core.result.ResponseResult;
import com.bw.core.utils.StringUtils;
import com.bw.user.pojo.TbBankInfo;
import com.bw.user.service.TbBankCardAuthService;
import com.bw.user.service.TbBankInfoService;
import com.bw.user.vo.BankCardVo;
import com.bw.user.vo.TiedCardReqVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 银行卡认证表&信息 前端控制器
 * </p>
 *
 * @author lv
 * @since 2021-03-23
 */
@RestController
@RequestMapping("/tb-bank-card-auth")
public class TbBankCardAuthController {

    @Autowired
    private TbBankInfoService bankInfoService;
    @Autowired
    private TbBankCardAuthService bankCardAuthService;

    @GetMapping("list")
    public List<TbBankInfo> list(){
        return bankInfoService.list();
    }

    /**
     *
     * @param bankcardVo
     * @return
     * 确认绑卡
     */
    @PostMapping("/bankcard")
    public ResponseResult bankcard(@RequestBody BankCardVo bankcardVo)
    {
        if (ObjectUtil.isNull(bankcardVo)){
            return ResponseResult.error("对象不存在");
        }
        return bankCardAuthService.bankcard(bankcardVo);
    }

    /**
     *
     * @param tiedCardReqVo
     * @return
     * 绑卡发送验证码
     */
    @PostMapping("/banksms")
    public ResponseResult bandsms(@RequestBody TiedCardReqVo tiedCardReqVo)
    {
        if (ObjectUtil.isNull(tiedCardReqVo)){
            return ResponseResult.error("对象不存在");
        }
        return bankCardAuthService.banksms(tiedCardReqVo);
    }


}
